<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="日程" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link href="/css/base.css" rel="stylesheet" type="text/css">
<link href="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css">
<script src="/js/popup_ext.js"></script>
<script src="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<script language="javascript">
	function doSave(contFlag){
		document.getElementById("buttonDiv").style.display="none";
		document.getElementById("waitDiv").style.display="";
		document.getElementById("continue_flag").value=contFlag;
		frm.submit();
	}
	function doReply(parentId){
		window.location="EstablishmentCommunicateNew.ihtm?parent_id="+parentId;
	}
	function doCancel(){
		parent.ClosePop();
	}
	function showMe(){
		if(checkNavigator()[0]!="msie" && parent.document.getElementById("dialogBox")){
			document.getElementById("attach_file").className="";
		}
		showFormErrorMsg();
		var childrenNum=${fn:length(command.childrenList)};
		if(childrenNum>0){
			document.getElementById("childrenDiv").style.display="";
		}
		document.getElementById("communicate.title").focus();
	}
	function changeTimeSelect(obj,targetName){
		document.getElementById(targetName).value=obj.value;
	}
	function selectCommunicater(){
		var url="/base/StafferMainForSelect.ihtm";
		ShowIframe("选择员工",url,800,500,"selectCommunicaterCallBack()",980,440);
	}
	function selectCommunicaterCallBack(){
		if(popRetVal!=null){
			var arr=popRetVal.split(";");
			document.getElementById("communicate.communicaterName").value=arr[1];
		}
	}
	function selectEst(){
		var url="/base/EstablishmentListForSelect.ihtm?type=CLIENT";
		ShowIframe("选择客户",url,900,500,"selectEstCallBack()",980,440);
	}
	function selectEstCallBack(){
		if(popRetVal!=null){
			document.getElementById("communicate.estId").value=popRetVal[0];
			document.getElementById("estName").value=popRetVal[1];
		}
	}
	function changeCommType(){
		if(document.getElementById("commType1").checked){
			document.getElementById("communicate.commType").value="LOG";
			document.getElementById("forAllTr").style.display="none";
			document.getElementById("smsRemindTr").style.display="none";
		}else{
			document.getElementById("communicate.commType").value="PLAN";
			document.getElementById("forAllTr").style.display="";
			document.getElementById("smsRemindTr").style.display="";
		}
	}
	function changeForAll(){
		if(document.getElementById("forAll1").checked){
			document.getElementById("communicate.forAll").value="Y";
		}else{
			document.getElementById("communicate.forAll").value="N";
		}
	}
	function changeSmsRemind(){
		if(document.getElementById("communicate.smsRemind").value=="Y"){
			document.getElementById("srDateStr").disabled=false;
			document.getElementById("srDateHourSelect").disabled=false;
			document.getElementById("srDateMinuteSelect").disabled=false;
		}else{
			document.getElementById("srDateStr").disabled=true;
			document.getElementById("srDateHourSelect").disabled=true;
			document.getElementById("srDateMinuteSelect").disabled=true;
		}
	}
	function showReceiver(){
		<c:if test="${command.canEdit=='Y'}">
		if(document.getElementById("forAll2").checked){
			var url="/base/EstCommReceiverList.ihtm";
			<c:if test="${id==null || id==''}">url=url+"?tmp_code=${command.tmpCode}";</c:if>
			<c:if test="${id!=null && id!=''}">url=url+"?comm_id=${id}";</c:if>
			ShowIframe("参与人员",url,350,400,"");
		}
		</c:if>
	}
	function doDelete(id){
		ShowConfirm('确认框','确定删除吗？',340,80,"doDelAct("+id+")");
	}
	function doDelAct(id){
		if(popRetVal!=null){
			window.location="/base/EstablishmentCommunicateDelete.ihtm?id="+id;
		}
	}
	function doComplete(id){
		var url="/base/EstCommCompForm.ihtm?id="+id;
		ShowIframe("完成情况",url,600,300,"doCompCallback()");
	}
	function doCompCallback(){
		if(popRetVal!=null){
			window.location.reload(true);
		}
	}
	function doSms(commId){
		var content="<fmt:formatDate value="${command.communicate.communicateTime}" pattern="MM-dd HH:mm"/> ${command.communicate.title}";
		var url="/sms/SmsSendForm.ihtm?comm_id="+commId+"&content="+encodeURIComponent(content);
		showWin(900,500,url);
	}
	function showExt(){
		if(document.getElementById("extTbl").style.display=="none"){
			document.getElementById("extTbl").style.display="";
			document.getElementById("extSpan").innerHTML="隐藏更多内容";
		}else{
			document.getElementById("extTbl").style.display="none";
			document.getElementById("extSpan").innerHTML="展开更多内容";
		}
	}
</script>
</head>
<body onLoad="showMe();" class="sheet modal-dialog" style=" padding-top:10px;">
<div class="sheet-main" id="bodyDiv" style="width:940px;">
	<form name="frm" method="post" enctype="multipart/form-data">
	  <div class="sheet-list" style="width:100%;">
	    <div class="modal-main search-business">
	    	<div style="width:100%;">
				<c:if test="${id==null || id==''}"><c:set var="pageTopTitle" value="新增日程" /></c:if>
				<c:if test="${id!=null && id!=''}"><c:set var="pageTopTitle" value="编辑日程" /></c:if>
				<%@ include file="../inc/PageTop.jsp"%> 
				<table border="0" cellspacing="1" cellpadding="1" align="center" class="table-a2">
					<tr>
				      	<th><span class="MustInput">*</span>主题：</th>
				      	<spring:bind path="command.communicate.title">
				      	<td>
							<input type="text" maxlength="50" class="TextBox" style="width:160px" onKeyUp="goNextInput('communicate.content');" id="${status.expression}" name="${status.expression}" value="${status.value}">
					        <script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',2,'communicate.title');
					        </script>
				     	</td>
				     	</spring:bind>
				      	<th><span class="MustInput">*</span>日期：</th>
				     	<spring:bind path="command.communicateTimeStr">
				     	<td>
							<input type="text" class="TextBox Datetime" maxlength="15" id="${status.expression}" name="${status.expression}" value="${status.value}"><img src="/images/calendar.gif" style="cursor:pointer" onClick="displayCalendar(document.getElementById('communicateTimeStr'),'yyyy-mm-dd',this);">
							<select id="orderDateHourSelect" onChange="changeTimeSelect(this,'communicateTimeHour');">
								<c:forEach var="item" begin="0" step="1" end="23" varStatus="i"><c:if test="${i.index<10}"><c:set var="item" value="0${item}" /></c:if><option value="${item}" <c:if test="${item==command.communicateTimeHour}">selected</c:if>>${item}</option></c:forEach>
							</select>
							<select id="orderDateMinuteSelect" onChange="changeTimeSelect(this,'communicateTimeMinute');">
								<c:forEach var="item" begin="0" step="1" end="59" varStatus="i"><c:if test="${i.index<10}"><c:set var="item" value="0${item}" /></c:if><option value="${item}" <c:if test="${item==command.communicateTimeMinute}">selected</c:if>>${item}</option></c:forEach>
							</select>
					          <script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',3,'communicateTimeStr');
					          </script>
				     	</td>
				     	</spring:bind>
						<th>客户：</th>
				      	<td>
							<spring:bind path="command.estName">
							<input type="text" class="TextBox readonly" readOnly="true" style="width:150px" id="${status.expression}" name="${status.expression}" value="${status.value}">
							<img class="make-a" src="/images/make-a.gif" onClick="selectEst();" style="cursor:pointer;" />
							</spring:bind>
							<spring:bind path="command.communicate.estId">
							  <input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}">
					          <script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',4);
					          </script>
							</spring:bind>
				     	</td>
				    </tr>
					<tr>
				    	<th><span class="MustInput">*</span>内容：</th>
				    	<spring:bind path="command.communicate.content">
				    	<td colspan="5">
				    		<textarea class="TextBox" style="width:600px;height:120px" id="${status.expression}" name="${status.expression}"><c:out value="${status.value}" /></textarea>
					          <script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',5,'communicate.content');
					          </script>
				    	</td>
				    	</spring:bind>
				    </tr>
				    <tr>
						<th>附件：</th>			    	
				    	<td colspan="5">
				    		<input type="file" class="TextBox" style="width:300px" name="attach_file" id="attach_file">
							<c:if test="${command.communicate.attachFile!=null && command.communicate.attachFile!=''}">
								<a href="${command.communicate.attachFile}" target="_blank">${command.attachFileName}</a>
							</c:if>
							<spring:bind path="command.communicate.attachFile">
					          <script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',6);
					          </script>
					      	</spring:bind>
				    	</td>
					</tr>
					<tr>
				    	<th><span class="MustInput">*</span>类型：</th>
				    	<td colspan="5">
							<c:if test="${id==null || id==''}">
								<span title="记录已发生的活动"><input type="radio" name="commType" id="commType1" onClick="changeCommType();" <c:if test="${command.communicate.commType=='LOG'}">checked="true"</c:if> <c:if test="${id!=null && id!=''}">disabled="true"</c:if>>工作日志</span>
								<span title="安排下一步的工作"><input type="radio" name="commType" id="commType2" onClick="changeCommType();" <c:if test="${command.communicate.commType=='PLAN'}">checked="true"</c:if> <c:if test="${id!=null && id!=''}">disabled="true"</c:if>>工作计划</span>
								<spring:bind path="command.communicate.commType">
									<input type="hidden" name="${status.expression}" id="${status.expression}" value="${status.value}">
								</spring:bind>
							</c:if>
							<c:if test="${id!=null && id!=''}">
								<c:if test="${command.communicate.commType=='LOG'}">工作日志</c:if>
								<c:if test="${command.communicate.commType=='PLAN'}">工作计划</c:if>
							</c:if>
							<a href="javascript:showExt();"><span id="extSpan">展开更多内容</span></a>
				    	</td>
				    </tr>
				</table>
				<table border="0" cellspacing="1" cellpadding="1" align="center" class="table-a2" id="extTbl" style="display:none">
					<tr>
						<th style="height:0px"></th>
						<td></td>
						<th></th>
						<td></td>
						<th></th>
						<td></td>
					</tr>
				    <tr>
						<th>上级任务：</th>
						<spring:bind path="command.parentTitle">
				    	<td colspan="5">
				    		<input type="text" class="TextBox readonly" readonly="true" style="width:300px" name="${status.expression}" id="${status.expression}" value="${status.value}">
				    	</td>
				    	</spring:bind>
					</tr>
					<tr id="forAllTr" <c:if test="${command.communicate.commType=='LOG'}">style="display:none"</c:if>>
			    		<th><span class="MustInput">*</span>是否公开：</th>
				    	<td colspan="5">
							<input type="radio" name="forAll" id="forAll1" onClick="changeForAll();" <c:if test="${command.communicate.forAll=='Y'}">checked</c:if>>全员公开
							<input type="radio" name="forAll" id="forAll2" onClick="changeForAll();" <c:if test="${command.communicate.forAll=='N'}">checked</c:if>>指定参与人
							<span><a href="javascript:showReceiver();">设置参与人员...</a></span>
							<spring:bind path="command.communicate.forAll">
								<input type="hidden" name="${status.expression}" id="${status.expression}" value="${status.value}">
							</spring:bind>
				    	</td>
				    </tr>
					<tr id="smsRemindTr" <c:if test="${command.communicate.commType=='LOG'}">style="display:none"</c:if>>
			    		<th><span class="MustInput">*</span>定时提醒：</th>
				    	<td colspan="5">
							<spring:bind path="command.communicate.smsRemind">
							<select name="${status.expression}" id="${status.expression}" onChange="changeSmsRemind();">
								<option value="Y" <c:if test="${status.value=='Y'}">selected</c:if>>是</option>
								<option value="N" <c:if test="${status.value=='N'}">selected</c:if>>否</option>
							</select>
							</spring:bind>
							<spring:bind path="command.srDateStr">
							<input type="text" class="TextBox Datetime" maxlength="15" id="${status.expression}" name="${status.expression}" value="${status.value}" <c:if test="${command.communicate.smsRemind=='N'}">disabled="true"</c:if>>
					          <script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',6,'srDateStr');
					          </script>
							</spring:bind>
							<img src="/images/calendar.gif" style="cursor:pointer" onClick="displayCalendar(document.getElementById('srDateStr'),'yyyy-mm-dd',document.getElementById('parentTitle'));">
							<select id="srDateHourSelect" onChange="changeTimeSelect(this,'srDateHour');" <c:if test="${command.communicate.smsRemind=='N'}">disabled="true"</c:if>>
								<c:forEach var="item" begin="0" step="1" end="23" varStatus="i"><c:if test="${i.index<10}"><c:set var="item" value="0${item}" /></c:if><option value="${item}" <c:if test="${item==command.srDateHour}">selected</c:if>>${item}</option></c:forEach>
							</select>
							<select id="srDateMinuteSelect" onChange="changeTimeSelect(this,'srDateMinute');" <c:if test="${command.communicate.smsRemind=='N'}">disabled="true"</c:if>>
								<c:forEach var="item" begin="0" step="1" end="59" varStatus="i"><c:if test="${i.index<10}"><c:set var="item" value="0${item}" /></c:if><option value="${item}" <c:if test="${item==command.srDateMinute}">selected</c:if>>${item}</option></c:forEach>
							</select>
							<span class="fei">（发送消息提醒自己与参与人）</span>
				    	</td>
				    </tr>
				</table>
				<table border="0" cellspacing="1" cellpadding="1" align="center" class="table-a2">
					<tr>
						<th style="height:0px"></th>
						<td></td>
						<th></th>
						<td></td>
						<th></th>
						<td></td>
					</tr>
					<tr>
						<th>&nbsp;</th>
						<td colspan="5">
							<p class="give">
								<span>注：工作日志只能当天修改，过期只有系统管理员admin可删除；工作计划的修改删除不受限制</span>
							</p>
							<c:if test="${id!=null && id!=''}">
							<p class="give">
								<span>创建人：${command.communicate.createrName}</span>
								<span>创建时间：<fmt:formatDate value="${command.communicate.createTime}" pattern="yyyy-MM-dd HH:mm"/></span>
								<c:if test="${command.communicate.completed=='Y'}"><span>完成时间：<fmt:formatDate value="${command.communicate.completeDate}" pattern="yyyy-MM-dd HH:mm"/></span></c:if>
							</p>
							</c:if>
						</td>
					</tr>
				</table>
				<div id="childrenDiv" style="width:100%;height:60px;OVERFLOW-Y:auto;display:none">
				<table class="table-b" align="center">
					<c:forEach var="item" items="${command.childrenList}">
						<tr>
							<th style="width:10%">&nbsp;</th>
							<td>
								<fmt:formatDate value="${item.communicateTime}" pattern="yyyy-MM-dd HH:mm"/>
								${item.createrName}
								${item.content}
								<c:if test="${item.attachFile!=null && item.attachFile!=''}">
									<a href="${item.attachFile}" target="_blank"><img src="/images/a32.gif" border="0"></a>
								</c:if>
							</td>
						</tr>
					</c:forEach>
				</table>
				</div>
			</div>
	  	</div>
	  </div>
		<div class="modal-buttom" id="buttonDiv">
			<input type="button" class="buttom-a" value=" 保 存 " onClick="doSave('');" <c:if test="${command.canEdit=='N'}">disabled="true"</c:if>>
			<c:if test="${id==null || id==''}">
				<input type="button" class="buttom-a" value="保存并新增" onClick="doSave('1');">
			</c:if>
			<c:if test="${id!=null && id!=''}">
				<input type="button" class="buttom-a" value=" 回复汇报 " onClick="doReply('${id}');">
				<c:if test="${command.communicate.commType=='PLAN'}">
					<input type="button" class="buttom-a" value=" 标记为完成 " onClick="doComplete('${id}');" <c:if test="${command.canEdit=='N'}">disabled="true"</c:if>>
					<input type="button" class="buttom-a" value=" 发短信 " onClick="doSms('${id}');" <c:if test="${currentUser.user.userType!=1 && fn:indexOf(currentUser.privs,';SMS_SEND_SIMP;')==-1}">disabled="true"</c:if>>
				</c:if>
				<input type="button" class="buttom-a" value=" 删 除 " onClick="doDelete('${id}');" <c:if test="${command.canEdit=='N' && currentUser.user.userType!=1}">disabled="true"</c:if>>
			</c:if>
			<input type="button" class="buttom-a" value=" 取 消 " onClick="doCancel();">
			<input type="hidden" name="continue_flag" id="continue_flag" value="0">
			<spring:bind path="command.communicateTimeHour"><input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}"></spring:bind>
			<spring:bind path="command.communicateTimeMinute"><input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}"></spring:bind>
			<spring:bind path="command.srDateHour"><input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}"></spring:bind>
			<spring:bind path="command.srDateMinute"><input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}"></spring:bind>
			<spring:bind path="command.tmpCode"><input type="hidden" id="${status.expression}" name="${status.expression}" value="${status.value}"></spring:bind>
		</div>
		<div class="modal-buttom" id="waitDiv" style="display:none">
			<span style="color:#ffffff">请稍候...</span>
		</div>
		
	</form>
</div>		
</body>
</html>
